Vortex gravity test.py (1022B)
1 import pygame, PyIgnition, sys 2 3 4 screen = pygame.display.set_mode((800, 600)) 5 clock = pygame.time.Clock() 6 7 effect = PyIgnition.ParticleEffect(screen) 8 gravity = effect.CreateVortexGravity(pos = (400, 300), strength = 1.0, strengthrandrange = 0.0) 9 particles = effect.CreateSource(pos = (0, 0), initspeed = 5.0, initdirectionrandrange = 0.5, particlesperframe = 5, particlelife = 200, drawtype = PyIgnition.DRAWTYPE_LINE, length = 5.0, radius = 5.0) 10 11 12 def Draw(): 13 screen.fill((255, 255, 255)) 14 15 effect.Update() 16 effect.Redraw() 17 18 pygame.draw.circle(screen, (255, 0, 100), (400, 300), 3) 19 20 mpos = pygame.mouse.get_pos() 21 #f = gravity.GetForce(mpos) 22 #endpos = [mpos[0] + f[0], mpos[1] + f[1]] 23 24 #pygame.draw.aaline(screen, (0, 0, 0), mpos, endpos) 25 particles.SetPos(mpos) 26 27 28 while True: 29 for event in pygame.event.get(): 30 if event.type == pygame.QUIT: 31 sys.exit() 32 33 Draw() 34 pygame.display.update() 35 clock.tick(30)